// pages/great-company/great-company.js
const app = getApp();
Page({
  data: {
    list:[],
    page:1,
    more:true
  },

  lookBtnTap:function(e){
    var id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/people-home/people-home?id=' + id,
    })
  },


  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getGreatCompanyList(); //获取企业列表
  },

  getGreatCompanyList:function(){
    var that = this;
    if(that.data.page==1){
      that.setData({
        list:[]
      })
    }
    wx.request({
      url: app.globalData.host + 'company/getGoodCompanyList',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      method: "GET",
      data: {
        page:that.data.page
      },
      success(res) {
        wx.hideNavigationBarLoading()
        wx.stopPullDownRefresh()
        if(res.data.data.list.last_page<=that.data.page){
          that.setData({
            more:false
          })
        }else{
          let hotPage = that.data.page + 1;
          that.setData({
            page:hotPage,
            more:true
          })
        }
       
        let lists=that.data.list.concat(res.data.data.list.data)
        that.setData({
          list:lists,
          topcompanyimglogo: res.data.data.system.topcompanyimglogo,
        })
      },
      fail(err) { },
      complete(comp) { },
    })

  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    wx.showNavigationBarLoading()
    this.setData({
      page:1
    })
    this.getGreatCompanyList()
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    let that=this
    if(that.data.more==true){
      that.getGreatCompanyList();
    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})